package com.yf.controller;

import com.yf.bean.*;
import com.yf.service.impl.ljxServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : hzyao
 * @date : 16:29 2020/10/7
 */
@Controller
@RequestMapping("ljx")
public class ljxController {
    @Autowired
    private ljxServiceImpl ljxService;

    @RequestMapping("/getBy8")
    public String getByLevel8(@Param("ch8") String ch8, Model model){
        ljx8  jx8 = ljxService.getByLevel8(ch8);
        if (jx8!=null){
            model.addAttribute("jx8",jx8);
            return "main";
        }else {
            model.addAttribute("error","不存在的翅号！请输入正确的翅号，或者选择正确的家系！");
            return "error";
        }

    }

    @RequestMapping("/getBy7/{lh7}")
    @ResponseBody
    public ljx7 getByLevel7(@PathVariable("lh7") String lh7){
        return ljxService.getByLevel7(lh7);
    }

    @RequestMapping("/getBy6/{lh6}")
    @ResponseBody
    public ljx6 getByLevel6(@PathVariable("lh6") String lh6){
        return ljxService.getByLevel6(lh6);
    }

    @RequestMapping("/getBy5/{lh5}")
    @ResponseBody
    public ljx5 getByLevel5(@PathVariable("lh5") String lh5){
        return ljxService.getByLevel5(lh5);
    }

    @RequestMapping("/getBy4/{lh4}")
    @ResponseBody
    public ljx4 getByLevel4(@PathVariable("lh4") String lh4){
        return ljxService.getByLevel4(lh4);
    }

    @RequestMapping("/getBy3/{lh3}")
    @ResponseBody
    public ljx3 getByLevel3(@PathVariable("lh3") String lh3){
        return ljxService.getByLevel3(lh3);
    }
}
